<template>
  <div class="details_container">
    <div @click="back" class="back">
      <span class="iconfont icon-fanhui"></span>
    </div>
    <van-swipe class="details_swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="(item,index) in gooddetail.pics" :key="index">
        <img width="100%" height="100%" :src="item.pic" alt />
      </van-swipe-item>
    </van-swipe>

    <div class="details_wrapper">
      <p style="font-size:.26rem;">{{gooddetail.basicInfo.name}}</p>
      <p style="font-size:.16rem;color:grey;">{{gooddetail.basicInfo.characteristic}}</p>
      <p class="details_title">
        <span style="color:red;font-size:.17rem;">
          低价
          <span style="color:red;font-size:.22rem;">￥{{gooddetail.basicInfo.minPrice}}</span>
          <span style="color:grey;">原价{{gooddetail.basicInfo.originalPrice}}</span>
        </span>
        <span style="color:grey;font-size:.17rem;">库存{{gooddetail.basicInfo.stores}}</span>
      </p>
    </div>

    <div class="details">
      <van-tabs class="details_tabs" v-model="active">
        <van-tab title="商品介绍">
          <div v-html="gooddetail.content" class="details_con"></div>
        </van-tab>
        <van-tab title="商品评价"></van-tab>
      </van-tabs>
    </div>
    <div class="nav-bottom">
      <div class="bottom-left">
        <div>
          <van-icon name="manager-o" size="22" />
        </div>
        <div @click="toCart">
           
          <van-icon name="shopping-cart-o" size="22" />

        </div>
        <div>
          <span v-show="!isShow" @click="white">
            <van-icon name="star-o" size="22" />
          </span>
          <span v-show="isShow" @click="yellow">
            <van-icon name="star" color="red" size="22" />
          </span>
        </div>
      </div>
      <div class="bottom-right">
        <span class="buy" @click="showPopup">立即购买</span>
        <span class="addcart">加入购物车</span>
      </div>
      <div>
        <van-popup v-model="show" closeable position="bottom">
          <div class="popupbuy">
            <div class="popupbuy-top-left">
              <img :src="gooddetail.basicInfo.pic" width="100%" />
            </div>
            <div class="popupbuy-top-right">
              <br />
              <p>{{gooddetail.basicInfo.name}}</p>
              <br />
              <p style="color:red">￥{{gooddetail.basicInfo.minPrice}}</p>
            </div>
          </div>
          <div class="popup-size">
            <div class="popup-box">
              <div
                v-for="(item,index) in gooddetail.properties"
                :key="index"
                style="font-size:22rem !important; "
              >
                <p>{{item.name}}</p>
                <p v-for="(item,index) in item.childsCurGoods" :key="index" class="spansize">
                  {{item.name}}
                </p>
              </div>
            </div>
          </div>
        </van-popup>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      active: 0,
      isShow: false,
      show: false
    };
  },
  mounted() {
    let id = this.$route.query.id;
    // console.log(id);
    this.$store.dispatch("getGoodDetail", id);
  },
  computed: {
    gooddetail: function() {
      return this.$store.state.goodModule.gooddetail;
    }
  },
  methods: {
    back() {
      window.history.back();
    },
    toCart() {
      this.$router.push({
        path: "/cart"
      });
    },
    showPopup() {
      this.show = true;
    },
    white() {
      this.isShow = true;
    },
    yellow() {
      this.isShow = false;
    }
  }
};
</script>

<style scoped>
.details_container {
  width: 100%;
  background-color: rgba(248, 245, 245, 0.863);
}
.back {
  width: 0.4rem;
  height: 0.4rem;
  /* border: 1px solid red; */
  border-radius: 50%;
  text-align: center;
  line-height: 0.4rem;
  background-color: #fff;
  color: #000;
  position: fixed;
  top: 0.15rem;
  left: 0.15rem;
  z-index: 3;
}
.details_swipe {
  width: 100%;
  height: 7rem;
}
.details_wrapper {
  width: 100%;
  height: 1.3rem;
  box-sizing: border-box;
  padding: 0.1rem;
  line-height: 0.4rem;
  background-color: #fff;
}
.details_title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.details {
  width: 100%;
  margin-top: 0.15rem;
  box-sizing: border-box;
  padding: 0.05rem;
  background-color: #fff;
}
.details_tabs {
  width: 100%;
}
.details_con >>> img {
  width: 100% !important;
  height: 100% !important;
}
.details_con >>> li {
  height: 0.47rem;
  line-height: 0.27rem;
  font-size: 0.2rem;
  padding-left: 0.14rem;
  padding-right: 0.24rem;
  padding-top: 0.2rem;
}
.nav-bottom {
  width: 100%;
  height: 1rem;
  background: white;
  position: fixed;
  bottom: 0px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
}
.bottom-left {
  flex: 1;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.bottom-left div {
  border-left: 1px solid #eee;
  padding-left: 0.3rem;
  padding-top: 0.3rem;
  padding-bottom: 0.15rem;
}
.bottom-right {
  flex: 1.5;
  display: flex;
  justify-content: space-around;
  align-items: center;
  text-align: center;
}
.bottom-right span {
  font-size: 0.3rem !important;
  border-left: 1px solid #eee;
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
  padding-right: 0.2rem;
  padding-left: 0.2rem;
}
.buy {
  padding-left: 0.4rem !important;
}
.addcart {
  color: white;
  background: #b7282e;
}
.popupbuy {
  width: 100%;
  height: 2.2rem;
  display: flex;
  justify-content: space-between;
}
.popupbuy-top-left {
  flex: 1;
}
.popupbuy-top-left img {
  width: 1.5rem;
  height: 1.5rem;
  padding: 0.3rem;
}
.popupbuy-top-right {
  flex: 5;
  margin-top: 0.3rem;
}
.spansize{
  display: inline-block;
  padding: 0.1rem 0.2rem;
  border: 1px solid #eee;
  margin-left: 0.1rem;
  margin-top: 0.1rem;
  border-radius: 0.06rem;
  
}
</style>